package com.xiaoxin.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoxin.lease.model.entity.GraphInfo;
import com.xiaoxin.lease.model.enums.ItemType;
import com.xiaoxin.lease.web.admin.service.GraphInfoService;
import com.xiaoxin.lease.web.admin.mapper.GraphInfoMapper;
import com.xiaoxin.lease.web.admin.vo.graph.GraphVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author liubo
* @description 针对表【graph_info(图片信息表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class GraphInfoServiceImpl extends ServiceImpl<GraphInfoMapper, GraphInfo>
    implements GraphInfoService{

    @Override
    public List<GraphVo> selectGraphInfoByApartmentId(Long apartmentId) {
        List<GraphVo> graphVoList  = super.list(new LambdaQueryWrapper<GraphInfo>().eq(GraphInfo::getItemType, ItemType.APARTMENT).eq(GraphInfo::getItemId,apartmentId)).stream().map(f->{
            GraphVo graphVo = new GraphVo();
            graphVo.setName(f.getName());
            graphVo.setUrl(f.getUrl());
            return graphVo;
        }).toList();

        return graphVoList;
    }

}




